﻿/*****************************************************************//**
 * @file    FITKGraphObjectMarkBase.h
 * @brief   Graph object for mark base.
 *
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-05-24
 *********************************************************************/

#ifndef __FITKGRAPHOBJECTMARKBASE_H__
#define __FITKGRAPHOBJECTMARKBASE_H__

#include "FITKGraphObject3D.h"

#include "FITKVTKGraphAdaptorAPI.h"

// Forward declaration
class vtkPoints;
class vtkCellArray;
class vtkPolyData;
class vtkUnstructuredGrid;
class vtkGlyph3D;
class vtkIntArray;
class vtkCell;

class FITKGraphActor;
class vtkPointSource;

namespace Interface
{
    class FITKModelSet;
}

namespace Exchange
{
    /**
     * @brief   Graph object for mark base.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-05-24
     */
    class FITKVTKGRAPHADAPTORAPI FITKGraphObjectMarkBase : public FITKGraphObject3D
    {
        // Regist
        FITKGraphObjectRegist(FITKGraphObjectMarkBase, FITKGraphObject3D);
        FITKCLASS(Exchange, FITKGraphObjectMarkBase);

    public:
        /**
         * @brief   Constructor.
         * @param   caseData: The case data
         * @param   markData: The mark data object
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-24
         */
        FITKGraphObjectMarkBase(AbaqusData::FITKDataCase* caseData, Core::FITKAbstractDataObject* markData);

        /**
         * @brief   Destructor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-24
         */
        virtual ~FITKGraphObjectMarkBase() = default;

    protected:
        /**
         * @brief   Constructor.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-01
         */
        FITKGraphObjectMarkBase() = default;

        /**
         * @brief   Check if the component is valid.
         * @param   compId: The component id( Set or surface )
         * @return  Is valid
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-24
         */
        bool getComponentValid(int compId);

        /**
         * @brief   Clear the model ids and the visibility hash.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-24
         */
        virtual void clearModelsInfo();

        /**
         * @brief   Clear the data.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-24
         */
        virtual void clearData();

        /**
         * @brief   Generate the poly data for the component.[virtual]
         * @param   compId: The component data id
         * @param   ugrid: The location grid data
         * @param   modelIds: The locations' model ids( For updating visibility. )
         * @param   subSetIds: The sub set ids[quote]
         * @param   instanceId: The instance id of the component[default]
         * @param   removeNormals: Need to remove the normals array[default]
         * @return  Is OK
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-24
         */
        virtual bool generateComponentGridData(int compId, vtkUnstructuredGrid* ugrid, QList<int>& modelIds, QList<int>& subSetIds, int instanceId = -1, bool removeNormals = true);

        /**
         * @brief   Generate interactions or constraint actor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-24
         */
        virtual void generateGraph();

        /**
         * @brief   Get the cell's visibility by the given model visibility hash.
         * @param   cell: The cell
         * @param   ptModelIdArray: The point's model id array
         * @param   modelVisibilityHash: The model visibility hash[quote]
         * @return  Need to be visibile
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-24
         */
        bool getCellVisibilityWithModel(vtkCell* cell, vtkIntArray* ptModelIdArray, QHash<int, bool>& modelVisibilityHash);

        /**
         * @brief   Generate set or comp-set grid data.
         * @param   setGrid: The set grid data
         * @param   set: The set data object
         * @param   modelIds: The set's model ids
         * @param   instanceId: The instance id[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-24
         */
        void generateSetData(vtkUnstructuredGrid* setGrid, Interface::FITKModelSet* set, QList<int>& modelIds, int instanceId = -1);

        /**
         * @brief   Generate set or comp-set data.
         * @param   setGrids: The sets grid list[quote]
         * @param   set: The set data object
         * @param   modelIds: The set's model ids
         * @param   instanceId: The instance id[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-05-24
         */
        void generateSetDataPrivate(QList<vtkUnstructuredGrid*>& setGrids, Interface::FITKModelSet* set, QList<int>& modelIds, int instanceId = -1);

    };
}   // namespace Exchange

#endif // __FITKGRAPHOBJECTMARKBASE_H__
